JavaScript Output

JavaScript can "display" data in different ways:
  1. Writing into an HTML element, using innerHTML.
  2. Writing into the HTML output using document.write().
  3. Writing into an alert box, using window.alert().
  4. Writing into the browser console, using console.log().
About: JavaScript Print
JavaScript does not have any print object or print methods. You cannot access output devices from JavaScript. The only exception is that you can call the window.print() method in the browser to print the content of the current window.

  1. Using innerHTML or textContent
  2. 5 + 6 =

    5 + 6 =

  3. Using document.write()
  4. NOTE:Using document.write() after an HTML document is loaded, will delete all existing HTML.

  5. Using window.alert()
  6. window.alert(5 + 6); は alert(5 + 6); のように書くこともできる。
  7. Using console.log()
  8. For debugging purposes, you can call the console.log() method in the browser to display data.